<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="product_info" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="productAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/psi/product/CartogramProduct?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 产品基本信息 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品类别" prop="menu_class">
              <el-radio-group v-model="product_info.menu_class" onClick='javascript:updateFrom(this.value)'>
                <el-radio-button label="产品">产品</el-radio-button>
                <el-radio-button label="服务性产品">服务性产品</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品条形码" prop="product_barcode">
              <el-input v-model="product_info.product_barcode" readonly />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品分类" prop="product_classid">
              <el-select style='width:100%' v-model="product_info.product_classid">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in l_class" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="证书编号" prop="certificate_number">
              <el-input v-model="product_info.certificate_number" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品名称" prop="product_name">
              <el-input v-model="product_info.product_name" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品名称缩写" prop="product_namebar">
              <el-input v-model="product_info.product_namebar" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品型号" prop="product_model">
              <el-input v-model="product_info.product_model" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品规格" prop="product_norm">
              <el-input v-model="product_info.product_norm" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="每天生产能力" prop="throughput">
              <el-input v-model="product_info.throughput" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="能力单位" prop="throughput_unit">
              <el-input v-model="product_info.throughput_unit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="所属系列" prop="series_name">
              <el-select style='width:100%' v-model="product_info.series_name">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_produce_series" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品状态简要描述" prop="product_des">
              <el-input type="textarea" v-model="product_info.product_des" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 产品交易 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品交易性" prop="product_istran">
              <el-radio-group v-model="product_info.product_istran">
                <el-radio-button label="可交易">可交易</el-radio-button>
                <el-radio-button label="不可交易">不可交易</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始日期" prop="Product_begindate">
              <el-date-picker v-model="product_info.Product_begindate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="有效期限" prop="Product_valdate">
              <el-date-picker v-model="product_info.Product_valdate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 附加说明 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="简短描述" prop="product_simpledes">
              <el-input v-model="product_info.product_simpledes" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="具体描述" prop="product_spsimpledes">
              <el-input type="textarea" v-model="product_info.product_spsimpledes" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="productAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/psi/product/CartogramProduct?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ProductAdd',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        product_info: {
          menu_class: null,
          product_barcode: null,
          product_classid: null,
          certificate_number: null,
          product_name: null,
          product_namebar: null,
          product_model: null,
          product_norm: null,
          throughput: null,
          throughput_unit: null,
          product_unit: null,
          series_name: null,
          product_des: null,
          product_istran: null,
          Product_begindate: null,
          Product_valdate: null,
          product_simpledes: null,
          product_spsimpledes: null,
        },
        l_class: [],
        s_produce_series: [],
        loading: false,
        rules: {
          product_barcode: [{
            required: true,
            message: "产品条形码不能为空",
            trigger: 'blur',
          }],
          product_classid: [{
            required: true,
            message: "产品分类不能为空",
            trigger: 'blur',
          }],
          product_name: [{
            required: true,
            message: "产品名称不能为空",
            trigger: 'blur',
          }],
          product_namebar: [{
            required: true,
            message: "产品名称缩写不能为空",
            trigger: 'blur',
          }],
          product_model: [{
            required: true,
            message: "产品型号不能为空",
            trigger: 'blur',
          }],
          product_norm: [{
            required: true,
            message: "产品规格不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/product/ProductAction/productAdd?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      productAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/product/ProductAction/productAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/product/ProductDet/productDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
